


// 将10进制转2进制
function dec2bin(decNumber) {
    let stack = [];
    while (decNumber>=1) {
        stack.push(decNumber%2);
        decNumber = Math.floor(parseInt(decNumber/2));
    }

    let binaryString = '';
    while (stack.length) {
        binaryString += stack.pop()
    }

    return binaryString;

}
console.log(dec2bin(10));
console.log(dec2bin(100));
console.log(dec2bin(1000));
console.log(dec2bin(10000));



